/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.widget;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
//import com.umeng.analytics.pro.d;

import java.util.LinkedHashMap;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.xuexiang.templateproject.R;

/* compiled from: RlImageLoadingView.kt */
//@Metadata(d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\t\u0018\u00002\u00020\u0001:\u0001%B\u0011\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004B\u0019\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007B!\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\b\u001a\u00020\t¢\u0006\u0002\u0010\nJ\u001c\u0010\u0018\u001a\u00020\u00192\b\u0010\u0002\u001a\u0004\u0018\u00010\u00032\b\u0010\u001a\u001a\u0004\u0018\u00010\u0006H\u0002J\u000e\u0010\u001b\u001a\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001dJ\u0016\u0010\u001e\u001a\u00020\u00192\u0006\u0010\u001f\u001a\u00020\t2\u0006\u0010 \u001a\u00020\tJ\u000e\u0010!\u001a\u00020\u00192\u0006\u0010\"\u001a\u00020\u0013J\u0006\u0010#\u001a\u00020\u0019J\u0006\u0010$\u001a\u00020\u0019R\u000e\u0010\u000b\u001a\u00020\fX\u0082.¢\u0006\u0002\n\u0000R\u001a\u0010\r\u001a\u00020\tX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011R\u0010\u0010\u0012\u001a\u0004\u0018\u00010\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0001X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0015\u001a\u00020\u0001X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0017X\u0082.¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lcom/jcds/learneasy/widget/RlImageLoadingView;", "Landroid/widget/RelativeLayout;", d.R, "Landroid/content/Context;", "(Landroid/content/Context;)V", "attrs", "Landroid/util/AttributeSet;", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "defStyleAttr", "", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "mImageView", "Landroid/widget/ImageView;", "mIndex", "getMIndex", "()I", "setMIndex", "(I)V", "mOnEditClickListener", "Lcom/jcds/learneasy/widget/RlImageLoadingView$OnEditClickListener;", "mProgressBar", "mRlImageView", "mTvEdit", "Landroid/widget/TextView;", "init", "", "attributeSet", "loadImage", "url", "", "setNum", "index", "total", "setOnEditClickListener", "onEditClickListener", "showErrorView", "showLoading", "OnEditClickListener", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
/* loaded from: classes2.dex */
public final class RlImageLoadingView extends RelativeLayout {

    /* renamed from: a  reason: collision with root package name */
    public ImageView mImageView;

    /* renamed from: b  reason: collision with root package name */
    public RelativeLayout rlProgressBar;

    /* renamed from: c  reason: collision with root package name */
    public RelativeLayout rlImageView;

    /* renamed from: d  reason: collision with root package name */
    public TextView tvEdit;

    /* renamed from: e  reason: collision with root package name */
    public int mIndex;
    @Nullable

    /* renamed from: f  reason: collision with root package name */
    public OnEditClickListener mOnEditClickListener;

    /* compiled from: RlImageLoadingView.kt */
//    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&¨\u0006\u0006"}, d2 = {"Lcom/jcds/learneasy/widget/RlImageLoadingView$OnEditClickListener;", "", "onEditClick", "", "index", "", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
    /* loaded from: classes2.dex */
    public interface OnEditClickListener {
        void onEditClick(int i2);
    }


    public final class b implements RequestListener<Drawable> {
        public b() {
        }

        @Override
        public boolean onLoadFailed(@androidx.annotation.Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
            RelativeLayout relativeLayout = RlImageLoadingView.this.rlProgressBar;
            if (relativeLayout == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mProgressBar");
                relativeLayout = null;
            }
            relativeLayout.setVisibility(View.GONE);
            return false;
        }

        @Override
        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
            RelativeLayout relativeLayout = RlImageLoadingView.this.rlProgressBar;
            if (relativeLayout == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mProgressBar");
                relativeLayout = null;
            }
            relativeLayout.setVisibility(View.GONE);
            return false;
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public RlImageLoadingView(@Nullable Context context) {
        super(context);
        new LinkedHashMap();
        b(context, null);
    }

    public static final void e(RlImageLoadingView this$0, int i2, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        OnEditClickListener aVar = this$0.mOnEditClickListener;
        if (aVar != null && aVar != null) {
            aVar.onEditClick(i2 - 1);
        }
    }

    public final void b(Context context, AttributeSet attributeSet) {
        View.inflate(context, R.layout.view_imageview_loading, this);
        View findViewById = findViewById(R.id.imageView);
        Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(R.id.imageView)");
        this.mImageView = (ImageView) findViewById;
        View findViewById2 = findViewById(R.id.rlProgressBar);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "findViewById(R.id.rlProgressBar)");
        this.rlProgressBar = (RelativeLayout) findViewById2;
        View findViewById3 = findViewById(R.id.rlImageView);
        Intrinsics.checkNotNullExpressionValue(findViewById3, "findViewById(R.id.rlImageView)");
        this.rlImageView = (RelativeLayout) findViewById3;
        View findViewById4 = findViewById(R.id.tvEdit);
        Intrinsics.checkNotNullExpressionValue(findViewById4, "findViewById(R.id.tvEdit)");
        this.tvEdit = (TextView) findViewById4;
    }

    public final void d(@NotNull String url) {
        Intrinsics.checkNotNullParameter(url, "url");
        if (getContext() instanceof Activity) {
            Context context = getContext();
            Intrinsics.checkNotNull(context, "null cannot be cast to non-null type android.app.Activity");
            if (!((Activity) context).isFinishing()) {
                Context context2 = getContext();
                Intrinsics.checkNotNull(context2, "null cannot be cast to non-null type android.app.Activity");
                if (((Activity) context2).isDestroyed()) {
                    return;
                }
            } else {
                return;
            }
        }
        RequestBuilder<Drawable> requestBuilder = Glide.with(this).load(url).addListener(new b());
        ImageView imageView = this.mImageView;
        if (imageView == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mImageView");
            imageView = null;
        }
        requestBuilder.into(imageView);
    }

    public final int getMIndex() {
        return this.mIndex;
    }

    public final void setMIndex(int i2) {
        this.mIndex = i2;
    }

    public final void setNum(final int i2, int i3) {
        TextView textView;
        this.mIndex = i2;
        TextView textView2 = this.tvEdit;
        if (textView2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mTvEdit");
            textView2 = null;
        }
        textView2.setText("编辑" + i2 + '/' + i3);
        TextView textView3 = this.tvEdit;
        if (textView3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mTvEdit");
            textView = null;
        } else {
            textView = textView3;
        }
        textView.setOnClickListener(new View.OnClickListener() { // from class: d.m.b.n.e
//        JumpUtilsKt.h(textView, new View.OnClickListener() { // from class: d.m.b.n.e
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                RlImageLoadingView.e(RlImageLoadingView.this, i2, view);
            }
        });
    }

    public final void setOnEditClickListener(@NotNull OnEditClickListener onEditClickListener) {
        Intrinsics.checkNotNullParameter(onEditClickListener, "onEditClickListener");
        this.mOnEditClickListener = onEditClickListener;
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public RlImageLoadingView(@Nullable Context context, @NotNull AttributeSet attrs) {
        super(context, attrs);
        Intrinsics.checkNotNullParameter(attrs, "attrs");
        new LinkedHashMap();
        b(context, attrs);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public RlImageLoadingView(@Nullable Context context, @NotNull AttributeSet attrs, int i2) {
        super(context, attrs, i2);
        Intrinsics.checkNotNullParameter(attrs, "attrs");
        new LinkedHashMap();
        b(context, attrs);
    }
}